clear all
clc
n = input('number of classes: ');
% lambdav = 15;
% Lambdac= 10;
% [A,b,lb,ub] = Conditions( n , lambdav ,Lambdac );
% f = @(x)parameterfun(x,n,A,b);
% x0=myfunction(n,lambdav,Lambdac);
% [x,fval,exitflag,output,lambda] = fmincon(f,x0,A,b,[],[],lb,ub)

lambdav = [8];%car arrival rates %should convert it to a poisson 
Lambdac= [2:0.1:5.9];%suppose like cars arrival , one arrival devided to categories with the same probabilities
W=zeros(1,length(Lambdac));
MaxW = zeros(1,length(Lambdac));
Exits=zeros(1,length(Lambdac));
for j=1:length(lambdav)
for i=1:length(Lambdac)
[A,b,lb,ub] = Conditions( n , lambdav(j) ,Lambdac(i));
f = @(x)parameterfun(x,n,A,b);
% x0 = zeros(1,n);
x0=myfunction(n,lambdav(j),Lambdac(i));
[x,fval,exitflag,output,lambda] = fmincon(f,x0,A,b,[],[],lb,ub);
while exitflag ~= 1
x0=x;
[x,fval,exitflag,output,lambda] = fmincon(f,x0,A,b,[],[],lb,ub);
end
%Average of waitings
W(i)=fval;
% Exits(i)=exitflag;
Outs(i)=output;
% max of waitings 
Waitings=zeros(1,n);
Waitings=-A(1:n,1:n)*x(1:n) + b(1:n) ;
for k=1:n
Waitings(k)=1/Waitings(k);
end
MaxW(i) = max(Waitings);

% %waiting given by equal decisions 
% equaldeci=0.5*ones(n,1);
% Waitings=-A(1:n,1:n)*equaldeci + b(1:n) ;

% %waiting given by all of them charges to the next level 
% chargingdecision=zeros(n,1);
% Waitings=-A(1:n,1:n)*chargingdecision + b(1:n) ;

end
plot(Lambdac,W);
hold on
plot(Lambdac,MaxW);
hold on
end
%  
% lambdav = [5:0.1:15];%car arrival rates %should convert it to a poisson 
% Lambdac= [3];%suppose like cars arrival , one arrival devided to categories with the same probabilities
% W=zeros(1,length(lambdav));
% for j=1:length(Lambdac)
% for i=1:length(lambdav)
% W(i) = myfunction(n,lambdav(i),Lambdac(j));
% end
% % figure;
% diary('myTextLog.txt');
% plot(lambdav,W,'--');
% hold on
% end

